package com.accp.biz.impl;

import com.accp.biz.DoctorBiz;
import com.accp.biz.UsersBiz;
import com.accp.dao.DoctorDao;
import com.accp.dao.UsersDao;
import com.accp.pojo.Doctor;
import com.accp.pojo.Users;

import java.util.List;

//import com.accp.dao.EmailDao;
//import com.accp.dao.VacationDao;

/**
 * 用户业务实现类
 * @author Administrator
 *
 */
public class DoctorBizImpl implements DoctorBiz {

	private DoctorDao doctorDao;

	public void setDoctorDao(DoctorDao doctorDao) {
		this.doctorDao = doctorDao;
	}

	/**
	 * 查找所有医生（分页多条件）
	 * @param doctor
	 * @return
	 */
	public List<Doctor> selectByPage(String className, int pageNo, int pageSize, Doctor doctor){
		List<Doctor> list=doctorDao.selectByPage(className,pageNo,pageSize,doctor);
		return list;
	}

	/**
	 * 添加医生
	 * @param doctor
	 * @return
	 */
	public boolean add(Doctor doctor){
		boolean flag = false;
		if(doctorDao.add(doctor)){
			flag = true;
		}
		return flag;
	}

	/**
	 * 通过名字查找某个用户
	 */
	@Override
	public Doctor findByDoctorId(Integer id) {
		return doctorDao.findByDoctorId(id);
	}

	/**
	 * 更新用户信息
	 */
	@Override
	public boolean update(Doctor doctor) {
		return doctorDao.update(doctor);
	}

	/**
	 * 删除医生
	 * @param doctor
	 * @return
	 */
	public boolean deleteDoctor(Doctor doctor){
		boolean flag = false;
		if(doctorDao.deleteDoctor(doctor)){
			flag = true;
		}
		return flag;
	}
	/**
	 * 查看下一页
	 */
	@Override
	public int searchRecordsNextPage(int pageSize, String className,Doctor doctor) {
		int total = doctorDao.totalPage(className,doctor.getName());
		int pageNo = total / pageSize;
		if(total % pageSize > 0){
			pageNo++;
		}
		return pageNo;
	}

}
